package com.jzhao.jpre.model;

import java.math.BigDecimal;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.dao.DataAccessException;

import com.jzhao.jpre.model.dao.MerEjDao;


public class TestMerEj {
	public static void main(String[] args) {

		ApplicationContext context = new ClassPathXmlApplicationContext(
		"beans.xml");

		
		MerEjDao merEjDao = (MerEjDao) context.getBean("merEjDao");

		MerEj MerEj = new MerEj();
		
		
	/*
		try {
						
			merEj.setTranDate("20070101");
			merEj.setJourNo("00000032");
			merEj.setSrcJourNo("00000030");
			merEj.setTranStat("0");
			
	

			
		
			merEj.setMrchCode("00010002");
			merEj.setSubCode("001");
			merEj.setAcctNo("555");
			merEj.setDrCrFlag("1");
			merEj.setTranAtt("0");
			merEj.setTranAmt(new BigDecimal("0.01"));
			
			
			merEjDao.insert(merEj);
		} 
		catch (DataAccessException dae) {
			System.out.println("Insert Failed!");
		}
	
    
		
		try {
			merEjDao.updateTranStat("20070101","00000030","00010001","0001","2");
		} catch (DataAccessException dae) {
			System.out.println("update Failed!");
		}
		
	
		try {
			merEjDao.updateChkFlag("20070101","00000030","00010001","0001","2");
		} catch (DataAccessException dae) {
			System.out.println("update Failed!");
		}
		

		
		List merEjs = merEjDao.selectByJourNo("20070101","00000030");
		for (int i = 0; i < merEjs.size(); i++) {
			merEj = (MerEj) merEjs.get(i);
			if (merEj != null) {
				System.out.println("TranStat = " + merEj.getTranStat()+"end");
				System.out.println("SubCode = " + merEj.getSubCode()+"end");
				System.out.println("TranAmt = " + merEj.getTranAmt()+"end");
				System.out.println("Reserve1 = " + merEj.getReserve1()+"end");
			}
		}
		*/
		try {
			   Object[] stlmSum = new Object[2];
			stlmSum =	merEjDao.Stat("20080105", "02800001", "0", "0");
				System.out.println("1" + (Integer)(stlmSum[0]));
				System.out.println("1" + (BigDecimal)(stlmSum[1]));

		} catch (DataAccessException dae) {
			System.out.println("select Failed!");
			System.out.println(dae.getMessage());
		}
		
		/*
		 try {
			MerEj =merEjDao.selectByJourNoAndSubCode("20080105", "00012647", "02800001", "005");
		} catch (DataAccessException dae) {
			System.out.println("select Failed!");
			System.out.println(dae.getMessage());
		}
		
		
		List merEjs1 = merEjDao.selectByMrchCode("00010001","20070101","20070101");
		for (int i = 0; i < merEjs1.size(); i++) {
			merEj = (MerEj) merEjs1.get(i);
			if (merEj != null) {
				System.out.println("TranStat = " + merEj.getTranStat()+"end");
				System.out.println("SubCode = " + merEj.getSubCode()+"end");
				System.out.println("TranAmt = " + merEj.getTranAmt()+"end");
				System.out.println("Reserve1 = " + merEj.getReserve1()+"end");
			}
		}
		*/
	}
}

	